package com.imooc.miaosha.result;

import lombok.Getter;

/**
 * @author simple
 */
@Getter
public class CodeMsg {

    /**
     * 通用异常
     */

    public static final CodeMsg SUCCESS = new CodeMsg(0, "success");
    public static final CodeMsg SERVER_ERROR = new CodeMsg(500100, "服务端异常");
    public static final CodeMsg BIND_ERROR = new CodeMsg(500101, "参数校验异常：%s");
    /**
     * 登录模块 5002XX
     */

    public static final CodeMsg LOGIN_VO_NULL = new CodeMsg(500201, "登录信息不能为空");
    public static final CodeMsg MOBILE_NULL = new CodeMsg(500202, "手机号不能为空");
    public static final CodeMsg PASSWORD_NULL = new CodeMsg(500203, "登录密码不能为空");
    public static final CodeMsg MOBILE_FORMAT_ERROR = new CodeMsg(500204, "手机号格式错误");
    public static final CodeMsg USER_NOT_EXIST = new CodeMsg(500205, "用户不存在");
    public static final CodeMsg PASSWORD_ERROR = new CodeMsg(500206, "密码错误");
    private int code;
    private String msg;

    public CodeMsg fillArgs(Object... args) {
        int code = this.code;
        String message = String.format(this.msg, args);
        return new CodeMsg(code, message);
    }

    private CodeMsg(int code, String msg) {
        this.code = code;
        this.msg = msg;
    }
    //商品模块 5003XX

    //订单模块 5004XX

    //秒杀模块 5005XX
}
